import axios from 'axios';

// 创建axios实例
const request = axios.create({
  baseURL: process.env.REACT_APP_API_URL_GZ,
  withCredentials: false,
  timeout: 10 * 2000,
});

// 请求拦截器
request.interceptors.request.use(
  (config) => {
    config.headers['Content-Type'] = 'application/x-www-form-urlencoded';
    return config;
  },
  (error) => {
    return Promise.reject(error);
  }
);

// 添加响应拦截器
request.interceptors.response.use(
  function (response) {
    return response.data;
  },
  function (error) {
    console.log(error.response, 'error');
    return error.response;
  }
);

export default request;
